#include "mainwidget.h"
#include "ui_mainwidget.h"

MainWidget::MainWidget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::MainWidget)
{
    ui->setupUi(this);

    Logger().init();
    m_pLeftWidget=new LeftWidget(this);
    //告警规则
    m_pAlertManager=new AlertManager(this);
    //告警日志
    m_pAlertRecord=new AlertRecord(this);
    //告警通知
    m_pAlertNotice=new AlertNotice(this);

    ui->leftLayout->addWidget(m_pLeftWidget);
    ui->rightLayout->addWidget(m_pAlertManager);
    ui->rightLayout->addWidget((m_pAlertRecord));
    ui->rightLayout->addWidget(m_pAlertNotice);

    m_pAlertRecord->hide();
    m_pAlertNotice->hide();

    connect(m_pLeftWidget,&LeftWidget::showAlertManger,this,&MainWidget::onShowAlertManger);
    connect(m_pLeftWidget,&LeftWidget::showAlertRecord,this,&MainWidget::onShowAlertRecord);
    connect(m_pLeftWidget,&LeftWidget::showAlertNotice,this,&MainWidget::onShowAlertNotice);
}

AlertManager* MainWidget::get_m_pAlertManager()
{
    return m_pAlertManager;
}


MainWidget::~MainWidget()
{
    delete ui;
}

void MainWidget::onShowAlertManger()
{
    m_pAlertNotice->hide();
    m_pAlertRecord->hide();
    m_pAlertManager->show();
}

void MainWidget::onShowAlertRecord()
{
    m_pAlertManager->hide();
    m_pAlertNotice->hide();
    m_pAlertRecord->show();
}

void MainWidget::onShowAlertNotice()
{
    m_pAlertManager->hide();
    m_pAlertRecord->hide();
    m_pAlertNotice->show();
}
